import React, { Component } from 'react'
import axios from 'axios'

export default class App extends Component {
  getStudentData = async()=>{
    try {
      const res = await axios.get("http://localhost:3000/api1/students")
      console.log(res)
    } catch (error) {
      console.log(error)
    }
  }

  getCarData = async()=>{
    try {
      const res = await axios.get("http://localhost:3000/api2/cars")
      console.log(res)
    } catch (error) {
      console.log(error)
    }
  }

  render() {
    return (
      <div>
        <button onClick={this.getStudentData}>点我获取学生数据</button>
        <button onClick={this.getCarData}>点我获取汽车数据</button>
      </div>
    )
  }
}
